package org.doubango.imsdroid.Services.strategy.bringtofront;

import org.doubango.imsdroid.IMSDroid;
import org.doubango.imsdroid.Main;

import android.content.Intent;

public class BringToFrontActionBased implements IBringToFrontStrategy{
	
	@Override
	public boolean bringToFront(int action, String[]... args) {
		Intent intent = new Intent(IMSDroid.getContext(), Main.class);
		try{
			intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP  | Intent.FLAG_ACTIVITY_NEW_TASK);
			intent.putExtra("action", action);
			for(String[] arg : args){
				if(arg.length != 2){
					continue;
				}
				intent.putExtra(arg[0], arg[1]);
			}
			IMSDroid.getContext().startActivity(intent);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
}
